package com.wc.alorithm_luogu.P3368;

import java.io.*;

/**
 * @Author congege
 * @Description 树状数组 2
 * https://www.luogu.com.cn/problem/P3368
 * @Date Created in 2023/12/6-10:52
 */
public class Main {
    static class Node {
        int l;
        int r;
        int sum;
        int lazy;
    }

    static Node[] tree;
    static int[] array;
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) {
        int n = nextInt();
        int m = nextInt();
        array = new int[n + 1];
        tree = new Node[n * 4];
        for (int i = 1; i <= n; i++) {
            array[i] = nextInt();
        }
        build(1, 1, n);
        while (m-- > 0) {
            int op = nextInt();
            int x = nextInt();
            if (op == 1) {
                int y = nextInt();
                int k = nextInt();
                add(1, x, y, k);
            } else {
                out.println(querySum(1, x, x));
            }
        }
        out.flush();
    }

    public static void build(int p, int l, int r) {
        tree[p] = new Node();
        tree[p].l = l;
        tree[p].r = r;
        if (l == r) {
            tree[p].sum = array[l];
            return;
        }
        int lc = p << 1;
        int rc = lc + 1;
        int mid = (l + r) >> 1;
        build(lc, l, mid);
        build(rc, mid + 1, r);
        tree[p].sum = tree[lc].sum + tree[rc].sum;
    }

    // 向下传递懒标记
    public static void pushDown(int p) {
        if (tree[p].lazy != 0) {
            int lc = p << 1;
            int rc = lc + 1;
            int mid = (tree[p].l + tree[p].r) >> 1;
            tree[lc].lazy += tree[p].lazy;
            tree[rc].lazy += tree[p].lazy;
            tree[lc].sum += tree[p].lazy * (mid - tree[lc].l + 1);
            tree[rc].sum += tree[p].lazy * (tree[rc].r - (mid + 1) + 1);

            tree[p].lazy = 0;
        }
    }

    // 在[l,r]区间的数+k
    public static void add(int p, int l, int r, int k) {
        if (tree[p].l >= l && tree[p].r <= r) {
            // 打上懒标记，查询时候更新
            tree[p].lazy += k;
            tree[p].sum += k * (tree[p].r - tree[p].l + 1);
            return;
        }
        // 向下传递当前的懒标记
        pushDown(p);
        int lc = p << 1;
        int rc = lc + 1;
        int mid = (tree[p].l + tree[p].r) >> 1;
        if (mid >= l) {
            add(lc, l, r, k);
        }
        if (mid + 1 <= r) {
            add(rc, l, r, k);
        }
        tree[p].sum = tree[lc].sum + tree[rc].sum;
    }

    // 查找区间和
    public static int querySum(int p, int l, int r) {
        if (tree[p].l >= l && tree[p].r <= r) {
            return tree[p].sum;
        }
        if (tree[p].l > r || tree[p].r < l) {
            return 0;
        }
        pushDown(p);
        int lc = p << 1;
        int rc = lc + 1;
        int mid = (tree[p].l + tree[p].r) >> 1;
        int sum = 0;
        if (mid >= l) {
            sum += querySum(lc, l, r);
        }
        if (mid + 1 <= r) {
            sum += querySum(rc, l, r);
        }
        return sum;
    }

    public static int nextInt() {
        try {
            in.nextToken();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (int) in.nval;
    }
}
